/*
* @file bsp_keyh
* @brief  Key driver header file
* @author feiniao
* @version 1.0
* @date 2025-5-11
* @note This code is designed to work with ESP32-S3 and uses the ESP-IDF 5.2.3 framework.
*/



#ifndef _KEY_H_
#define _KEY_H_

#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "esp_log.h"
#include "freertos/semphr.h"
#include "esp_timer.h"
#include "global_msg.h"

#define TAG "KEY"

class BSP_KEY {
public:
    BSP_KEY(gpio_num_t key_gpio_num);
    ~BSP_KEY();
    int get_key_num();  // 轮询方式检测按键

private:
    gpio_num_t key_gpio_num;
    bool debounce = false;  // 防抖标志
    uint64_t last_press_time = 0;
};


#endif


/*
example usage:
#include "bsp_key.h"
extern "C" void app_main() {
    BSP_KEY key(GPIO_NUM_10);
    while (1) {
        vTaskDelay(pdMS_TO_TICKS(100));
        (void)key_num = key.get_key_num();
    }
}
*/